using System.Collections.Generic;
using UnityEngine;

public class MeteoreApparition : MonoBehaviour
{
	public Vector2 blocPoolPosition = new Vector2(10f, 3f);

	public float fireTime = 10f;

	public GameObject bloc;

	public float MinPosition;

	public float MaxPosition;

	public int pooledAmount = 3;

	public float xpos;

	private List<GameObject> blocs;

	public bool Enable;

	private void Start()
	{
		blocs = new List<GameObject>();
		for (int i = 0; i < pooledAmount; i++)
		{
			GameObject gameObject = Object.Instantiate(bloc);
			gameObject.SetActive(false);
			blocs.Add(gameObject);
		}
		InvokeRepeating("CreaBlocs", fireTime, fireTime);
	}

	private void CreaBlocs()
	{
		if (!Enable)
		{
			return;
		}
		xpos = Random.Range(MinPosition, MaxPosition);
		for (int i = 0; i < blocs.Count; i++)
		{
			if (!blocs[i].activeInHierarchy)
			{
				blocs[i].transform.position = new Vector3(base.gameObject.transform.position.x + xpos, 40f, 0f);
				blocs[i].transform.rotation = base.transform.rotation;
				blocs[i].SetActive(true);
				break;
			}
		}
	}
}
